export default {
  data() {
    return {
    };
  },
  methods: {
    textareaArr(str) {
      if (typeof str == "string") {
        return str.split(/[(\r\n)\r\n]+/);
      } else {
        return [];
      }
    }, 
    onOk() {
      let textareaArr = this.textareaArr(this.industryParams.options);
      if (textareaArr.length == 1 && !textareaArr[0]) {
        return [];
      }
      let options = [];
      textareaArr.map((item, index) => {
        if (item.trim()) {
          options.push({
            index: index + 1,
            optiondisplay: item,
            optionvalue: index + 1
          });
        }
      });
      return options;
    },
    textareaStr(arr) {
      if (Array.isArray(arr)) {
        return arr.join("\n");
      } else {
        return "";
      }
    },
    load() {
      const val = this.thisItem.options;
      this.oldVal = val;
      this.$nextTick(() => {
        let data = [];
        this.oldVal.map(item => {
          data.push(item.optiondisplay);
        });
        return this.textareaStr(data);
      });
    },
    handleClose() {
      this.industryParams = {
        columnid: '',
        columnname: '',
        datatype: '', 
        enable: true,
        moduleCode: '', 
        options: ''
      };
    },
  }
};